<?php
	require_once("includes/DBFunctions.php");
	
	$db = new DBFunctions;
	$db -> connectDB();
	$selectSpecies;
	$selectRegion;
	$results = $db->query("SELECT Species_ID, CommonName FROM Species;");
	while( $line = mysqli_fetch_array( $results, MYSQL_ASSOC ) ) {
		$selectSpecies .= "<option value='".$line['Species_ID']."'>".$line['CommonName']."</option>";
	}
	$results = $db->query("SELECT Region_ID, Name FROM Region;");
	while( $line = mysqli_fetch_array( $results, MYSQL_ASSOC ) ) {
		$selectRegion .= "<option value='".$line['Region_ID']."'>".$line['Name']."</option>";
	}
	$db->closeDB();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <title>Species Migration Model</title>
	<link rel="stylesheet" href="style.css" type="text/css" />
    <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAKU9Gv63dah1WqFl1797MlRSYVjwWdy7AbhNDg-RDrYETHew2-RSMwoJRrQ56Aj6TtmnHlKWs4v1HbQ" type="text/javascript"></script>
	<script src="map.js" type="text/javascript"></script>
	<script src="tlabel.js" type="text/javascript"></script>
  </head>
  <body onunload="GUnload()">
	<div id="content">
		<div id="top">
			<div class="left">Hello, Mark</div>
			<div class="right"><a href="#">Log Out</a></div>
		</div>
		<div id="map"></div>
		<div id="sidebar">
			<div id="viewOptions">
				<h3>View Options</h3>
				<select id="species" name="species" onchange="showPopulation('functors/displayPopulationBySpeciesFunctor.php');">
					<option value="">Select Species</option>
					<?php print $selectSpecies ?>
				</select>
				<select name="envEventsSelect">
					<option value="">Select Environment Event</option>
				</select>
				<input type="checkbox" name="survivability" id="survivability" value="Survivability Index"/>Survivability
				<input type="checkbox" name="population" value="Population"/>Population
			</div>
			<input type="button" name="nextYear" value="Next Year" onclick="call('functors/decrementTimeFunctor.php');">
			<input type="button" name="printOut" value="Print Out" onclick="getMarkers_AJAX('test.php');">
		</div>
		<div id="bottom">
			<form name="addSpeciesToRegion" method="post" onsubmit="addSpecies('functors/addSpeciesFunctor.php'); return false;">
				<select id="selectSpecies" name="selectSpecies">
					<option value="">Select Species</option>
					<?php print $selectSpecies ?>
				</select>
				<select id="selectRegion" name="selectRegion">
					<option value="">Select Region</option>
					<?php print $selectRegion ?>
				</select>
				<input id="population" type="text" name="population" value="0" id="setPop" />
				<input type="submit" value="Submit"/>
			</form>
		</div>
	</div>
	<script type="text/javascript">
		initialize();
	</script>
	<?php
		include("includes/SprocCalls.php");
		
		$sp = new SProcCalls;
		$sp -> displayRegionsProjectDemo();
		$sp -> displayPopulationProjectDemoWithTags(16,1);
		
	?>
  </body>
</html>